package com.hoshiicloud.shxping.feign;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hoshiicloud.common.rpc.Response;
import com.hoshiicloud.shxping.dto.*;
import com.hoshiicloud.shxping.feign.hystrix.HystrixUserFeignFallback;
import com.hoshiicloud.shxping.param.MemberAddressPageParam;
import com.hoshiicloud.shxping.param.MemberAddressUpdateParam;
import com.hoshiicloud.shxping.param.MemberWithConsumerParam;
import com.hoshiicloud.shxping.param.PlatStoreQueryParam;
import com.hoshiicloud.user.entity.store.PlatStore;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author yangcheng
 * @version 1.0
 * @title: UserFeignService
 * @description: 用户微服务FeignClient
 * @date 2019/7/20 15:36
 * @mail maiboyc@163.com
 */
@FeignClient(name = "hoshiicloud-user", fallback = HystrixUserFeignFallback.class)
public interface IUserFeignService {

    /**
     * 根据id获取租户
     * @param id ID
     * @return Response
     */
    @RequestMapping(value = "/company/company/{id}", method = RequestMethod.GET)
    Response<CompanyDto> getCompanyById(@PathVariable("id") Long id);

    /**
     * 根据租户会员ID获取租户会员信息
     * @param id 租户会员ID
     * @return Response
     */
    @RequestMapping(value = "/rbac/member/{id}", method = RequestMethod.GET)
    Response<MemberDto> getMemberById(@PathVariable("id") Long id);

    /**
     * 保存租户会员信息
     * @param memberDto 租户会员信息DTO
     * @return  Response
     */
    @RequestMapping(value = "/rbac/member/save", method = RequestMethod.POST)
    Response<Long> saveMember(@RequestBody MemberDto memberDto);

    /**
     * 更新租户会员信息
     * @param memberDto 租户会员信息DTO
     * @return  Response
     */
    @RequestMapping(value = "/rbac/member/update", method = RequestMethod.PUT)
    Response<Long> updateMember(@RequestBody MemberDto memberDto);

    /**
     * 根据WxOpenId查询租户会员
     * @param wxOpenId 微信用户唯一id
     * @return Response<MemberDto>
     */
    @RequestMapping(value = "/rbac/member/getMemberByWxOpenId", method = RequestMethod.GET)
    Response<MemberDto> getMemberByWxOpenId(@RequestParam("wxOpenId") String wxOpenId);

    /**
     * 根据手机号码查询租户会员
     * @param companyId 租户id
     * @param mobile 手机号码
     * @return Response<MemberDto>
     */
    @RequestMapping(value = "/rbac/member/getMemberByMobile", method = RequestMethod.GET)
    Response<MemberDto> getMemberByMobile(@RequestParam("companyId") Long companyId,@RequestParam("mobile") String mobile);

    /**
     * 根据微信openId和手机号码获取租户会员信息
     * @param wxOpenId 微信openId
     * @param phone 手机号码
     * @return Response<MemberDto>
     */
    @RequestMapping(value = "/rbac/member/getMemberByWxOpenIdOrMobile", method = RequestMethod.GET)
    Response<MemberDto> getMemberByWxOpenIdOrMobile(@RequestParam("wxOpenId") String wxOpenId, @RequestParam("phone") String phone);

    /**
     * 查询租户会员信息和平台会员信息
     * @param param 查询参数
     * @return Response<Map<String,Object>>
     */
    @RequestMapping(value = "/rbac/member/getMemberWithConsumerInfo", method = RequestMethod.POST)
    Response<Map<String,Object>> getMemberWithConsumerInfo(@RequestBody MemberWithConsumerParam param);

    /**
     * 根据参数查找租户会员信息
     * @param param 查询参数
     * @return  Response<List<MemberDto>>
     */
    @RequestMapping(value = "/rbac/member/getMembers", method = RequestMethod.POST)
    Response<List<MemberDto>> getMembers(@RequestBody MemberDto param);

    /**
     * 根据id获取平台会员
     * @param id ID
     * @return Response
     */
    @RequestMapping(value = "/usercenter/platConsumer/{id}", method = RequestMethod.GET)
    Response<ConsumerDto> getConsumerById(@PathVariable("id") Long id);

    /**
     * 根据参数查询平台会员信息
     * @param entity 查询参数实体
     * @return Response<List<ConsumerDto>>
     */
    @RequestMapping(value = "/usercenter/platConsumer/getConsumers", method = RequestMethod.POST)
    Response<List<ConsumerDto>> getConsumers(@RequestBody ConsumerDto entity);

    /**
     * 保存平台会员信息
     * @param entity 保存对象
     * @return Response<Long>
     */
    @RequestMapping(value = "/usercenter/platConsumer/save", method = RequestMethod.POST)
    Response<Long> saveConsumer(@RequestBody ConsumerDto entity);

    /**
     * 更新平台会员信息
     * @param entity 更新对象
     * @return Response<Long>
     */
    @RequestMapping(value = "/usercenter/platConsumer/update", method = RequestMethod.PUT)
    Response<Long> updateConsumer(@RequestBody ConsumerDto entity);

    /**
     * 保存平台会员账户
     * @param entity 保存对象
     * @return Response<Long>
     */
    @RequestMapping(value = "/memberAccount/save", method = RequestMethod.POST)
    Response<Long> saveMemberAccount(@RequestBody MemberAccountDto entity);

    /**
     * 保存会员收货地址
     * @param entity 会员收货地址实体
     * @return Response<Long>
     */
    @RequestMapping(value = "/memberAddress/save", method = RequestMethod.POST)
    Response<Long> addAddress(@RequestBody MemberAddressDto entity);

    /**
     * 修改会员收货地址
     * @param entity 会员收货地址修改参数实体
     * @return Response<Long>
     */
    @RequestMapping(value = "/memberAddress/update", method = RequestMethod.PUT)
    Response<Long> updateAddress(@RequestBody MemberAddressUpdateParam entity);

    /**
     * 删除会员收货地址
     * @param id 收货地址ID
     * @return Response<Long>
     */
    @RequestMapping(value = "/memberAddress/delete/{id}", method = RequestMethod.DELETE)
    Response<Long> deleteAddress(@PathVariable("id") Long id);

    /**
     * 查看会员收货地址
     * @param entity 查询参数实体
     * @return Response<Page<MemberAddressDto>>
     */
    @RequestMapping(value = "/memberAddress/list")
    Response<Page<MemberAddressDto>> viewAddress(@RequestBody MemberAddressPageParam entity);

    /**
     * 根据ID获取收货地址信息
     * @param id 收货地址ID
     * @return Response<MemberAddressDto>
     */
    @RequestMapping(value = "/memberAddress/{id}", method = RequestMethod.GET)
    Response<MemberAddressDto> getAddressById(@PathVariable("id") Long id);

    /**
     * 分页查询范围内的店铺列表
     * @param param 查询参数
     * @return Response<Page<Map<String, Object>>>
     */
    @RequestMapping(value = "/store/plat-store/storeRange",method = RequestMethod.POST)
    Response<Page<Map<String, Object>>> storeRange(@RequestBody PlatStoreQueryParam param);

    /**
     * 获取店铺详情
     * @param id 店铺ID
     * @return Response<PlatStoreDTO>
     */
    @GetMapping(value = "/store/plat-store/{id}")
    Response<PlatStoreDTO> queryById(@PathVariable("id") Long id);

    /**
     * 根据店铺ID获取店铺经营类目
     * @param storeId 店铺id
     * @return Response<List<Map<String,Object>>>
     */
    @RequestMapping(value = "/store/store-goods-category/getCategoriesByStoreId", method = RequestMethod.GET)
    Response<List<Map<String,Object>>> getCategoriesByStoreId(@RequestParam("storeId") Long storeId);

    /**
     * 分页查询店铺列表
     * @param param 查询参数
     * @return Response<Page<PlatStoreDTO>>
     */
    @RequestMapping(value = "/store/plat-store/getPage", method = RequestMethod.POST)
    Response<Page<PlatStoreDTO>> page(@RequestBody PlatStoreQueryParam param);

    /**
     * 根据平台ID获取店铺列表
     * @param platId 平台ID
     * @return Response<List<PlatStoreDTO>>
     */
    @RequestMapping(value = "/store/plat-store/getStoresByPlatId/{platId}", method = RequestMethod.GET)
    Response<List<PlatStoreDTO>> getStoresByPlatId(@PathVariable("platId") Long platId);

    /**
     * 批量更新店铺信息
     * @param storeDTOS 店铺列表
     * @return Response<List<Long>>
     */
    @RequestMapping(value = "/store/plat-store/batchUpdateStores", method = RequestMethod.POST)
    Response<List<Long>> batchUpdateStores(@RequestBody List<PlatStoreDTO> storeDTOS);

    /**
     * @Author qry
     * @Date 17:19 2019/9/2
     * 根据店铺
     **/
    @GetMapping("/store/plat-store/getByIds")
    Response<List<PlatStore>> getPlatStoreByIds(@RequestParam("ids")  List<Long> ids);
}
